﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public struct Contestant
        {
            public string name;
            public int rec1, rec2, rec3;
        }
        private Contestant[] cont;


        public enum Mark { 简单题 = 2, 中等题 = 5, 难题 = 8 };
        
        
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dgvGrades.RowCount; i++)
            {
                dgvGrades[4, i].Value = Int32.Parse(dgvGrades[1, i].Value.ToString()) * (int)Mark.简单题 + Int32.Parse(dgvGrades[2, i].Value.ToString()) * (int)Mark.中等题
                    + Int32.Parse(dgvGrades[3, i].Value.ToString()) * (int)Mark.难题;
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            cont = new Contestant[5];

            cont[0].name = "李  明"; cont[0].rec1 = 17; cont[0].rec2 = 10; cont[0].rec3 = 1;
            cont[1].name = "刘  丽"; cont[1].rec1 = 15; cont[1].rec2 = 11; cont[1].rec3 = 2;
            cont[2].name = "张小白"; cont[2].rec1 = 13; cont[2].rec2 = 13; cont[2].rec3 = 3;
            cont[3].name = "宋少杰"; cont[3].rec1 = 11; cont[3].rec2 = 12; cont[3].rec3 = 4;
            cont[4].name = "王彬彬"; cont[4].rec1 = 12; cont[4].rec2 = 14; cont[4].rec3 = 2;

            dgvGrades.RowCount = 5;
            for (int i = 0; i < dgvGrades.RowCount; i++)
            {
                dgvGrades[0, i].Value = cont[i].name;
                dgvGrades[1, i].Value = cont[i].rec1;
                dgvGrades[2, i].Value = cont[i].rec2;
                dgvGrades[3, i].Value = cont[i].rec3;
            }
        }
    }
}
